package com.erlang.spirngbootmybatis.service.imp;

import com.erlang.spirngbootmybatis.entity.Customer;
import com.erlang.spirngbootmybatis.mapper.CustomerMapper;
import com.erlang.spirngbootmybatis.mapper.UserMapper;
import com.erlang.spirngbootmybatis.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by IntelliJ IDEA.
 *
 * @author ZGQ
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    //因为主类的@MapperScan方法，所以自动为UserMapper装配了一个userMapper对象
    @Autowired
    private CustomerMapper customerMapper;

    //这里你传过去的时候user的id为null,而insert之后传回回来的user会把数据库中的id值带回来，真强大
    @Override
    public int add(Customer customer) {
        customerMapper.insert(customer);
        int id = customer.getId();
        return id;
    }
}
